#ifndef GAMEBOARD_H
#define GAMEBOARD_H

#include <QtGui/QMainWindow>
#include <Qlabel>
#include <QPushButton>
#include <vector>
#include <QGroupBox>
#include <QTextEdit>
#include <map>

#include "player.h"
#include "Territory.h"
#include "Region.h"
#include "cards.h"
#include "setupwindow.h"

using namespace std;

namespace Ui
{
    class GameBoardClass;
}

class GameBoard : public QMainWindow
{
    Q_OBJECT

public:
    GameBoard(QWidget *parent = 0);
    virtual ~GameBoard();

    //accessor methods
    typedef map<Territory*, QPushButton*> btnMap;
    typedef map<string, int> TerMap;
    vector<Player*> getPlayers() {return m_players;}
    vector<Cards*> getDeck() {return m_Deck;}
    vector<Region*> getRegions() {return m_regions;}

    void UpdateUI_CurrentPlayer(Player* currentPlayer);
    void UpdateUI_Phase(QString phase);
    void UpdateUI_Instr(QString instruction);

    void UpdateUI_Dice1(int val);
    void UpdateUI_Dice2(int val);
    void UpdateUI_Dice3(int val);
    void UpdateUI_Dice4(int val);
    void UpdateUI_Dice5(int val);

    //Updates color of territory
    void UpDateUI_TerritoryColor(Player* player, Territory* territory);

    //Updates label on territory to show reinforcements number
    void UpdateUI_TerritoryReinforcements(Territory* territory);


    void ViewCards(Player* CurrentPlayer);
    void HideCards();

    int movingArmies();

signals:
    void playCreateComp();

    //Signals emitted when Map Labels are clicked
    void selectedTerritory(Territory* clicked);
    void selectedCard(Cards* clicked);

    void nextBtn();
    void rollBtn();
    void stopRollBtn();
    void numArmiesChosen();
    void turnInCardsBtn();

public slots:
    void setSliderNum(Territory* ter);

private slots:   
    void BeebeClicked();
    void BurbsClicked();
    void DowntownClicked();
    void TransferClicked();
    void ALoungeClicked();
    void EEmersonClicked();
    void WEmersonClicked();
    void PageClicked();
    void PageMPRClicked();
    void PostOfficeClicked();
    void KerrwoodClicked();
    void LibraryClicked();
    void GardensClicked();
    void WittierClicked();
    void PorterHClicked();
    void MusicClicked();
    void PrayerChapelClicked();
    void DTRClicked();
    void PorterCClicked();
    void KSCClicked();
    void FoundersClicked();
    void DCClicked();
    void ObservatoryClicked();
    void WVKClicked();
    void EVKClicked();
    void BaseballClicked();
    void TrackClicked();
    void TrackHouse();
    void MRoomsClicked();
    void GymClicked();
    void PoolClicked();
    void PhysPlantClicked();
    void ReynoldsClicked();
    void HealthClicked();
    void WArmClicked();
    void CLoungeClicked();
    void EArmClicked();
    void DeaneClicked();
    void ArtClicked();
    void TennisClicked();

    void nextClicked();
    void rollClicked();
    void stopRollClicked();
    void selectNumArmies();
    void setPlayers(vector<Player*> players);
    void showNumMoveArmy(int value);
    void turnInCardsClicked();

    void CardClicked_1();
    void CardClicked_2();
    void CardClicked_3();
    void CardClicked_4();
    void CardClicked_5();

private:
    Ui::GameBoardClass *m_ui;

    vector<Player*>     m_players;
    vector<Cards*>      m_Deck;
    vector<Region*>     m_regions;

    Territory* m_BeebeHouse;
    Territory* m_Burbs;
    Territory* m_Downtown;
    Territory* m_Transfer;
    Territory* m_ALounge;
    Territory* m_EastEmerson;
    Territory* m_WestEmerson;
    Territory* m_Page;
    Territory* m_PageMPR;
    Territory* m_PostOffice;
    Territory* m_Kerrwood;
    Territory* m_Library;
    Territory* m_Gardens;
    Territory* m_Wittier;
    Territory* m_PorterHall;
    Territory* m_MusicBuilding;
    Territory* m_PrayerChapel;
    Territory* m_DTRPond;
    Territory* m_PorterCenter;
    Territory* m_KSC;
    Territory* m_Founders;
    Territory* m_DC;
    Territory* m_Observatory;
    Territory* m_EastVK;
    Territory* m_WestVK;
    Territory* m_Baseball;
    Territory* m_Track;
    Territory* m_TrackHouse;
    Territory* m_MRooms;
    Territory* m_Gym;
    Territory* m_Pool;
    Territory* m_PhysicalPlant;
    Territory* m_Reynolds;
    Territory* m_HealthCenter;
    Territory* m_WestArmington;
    Territory* m_CLounge;
    Territory* m_EastArmington;
    Territory* m_Deane;
    Territory* m_Art;
    Territory* m_TennisCourts;

    Region* m_Clark;
    Region* m_PageEmerson;
    Region* m_Central;
    Region* m_Athletic;
    Region* m_Armington;
    Region* m_VKDC;

    Cards* m_cBeebeHouse;
    Cards* m_cBurbs;
    Cards* m_cDowntown;
    Cards* m_cTransfer;
    Cards* m_cALounge;
    Cards* m_cEastEmerson;
    Cards* m_cWestEmerson;
    Cards* m_cPage;
    Cards* m_cPageMPR;
    Cards* m_cPostOffice;
    Cards* m_cKerrwood;
    Cards* m_cLibrary;
    Cards* m_cGardens;
    Cards* m_cWittier;
    Cards* m_cPorterHall;
    Cards* m_cMusicBuilding;
    Cards* m_cPrayerChapel;
    Cards* m_cDTRPond;
    Cards* m_cPorterCenter;
    Cards* m_cKSC;
    Cards* m_cFounders;
    Cards* m_cDC;
    Cards* m_cObservatory;
    Cards* m_cEastVK;
    Cards* m_cWestVK;
    Cards* m_cBaseball;
    Cards* m_cTrack;
    Cards* m_cTrackHouse;
    Cards* m_cMRooms;
    Cards* m_cGym;
    Cards* m_cPool;
    Cards* m_cPhysicalPlant;
    Cards* m_cReynolds;
    Cards* m_cHealthCenter;
    Cards* m_cWestArmington;
    Cards* m_cCLounge;
    Cards* m_cEastArmington;
    Cards* m_cDeane;
    Cards* m_cArt;
    Cards* m_cTennisCourts;
    Cards* m_Joker1;
    Cards* m_Joker2;

    void CreateTerritories();
    void LinkTerritories();
    void CreateRegions();
    void CreateCards();
    void CreateDeck();
    void MapTerritories();
    void MapButtons();




    //UI
    //Ui::GameBoardClass *m_ui;

    //Specific Labels
    QLabel* m_phase;
    QLabel* m_currentPlayer;
    QLabel* m_territory;
    QLabel* m_region;

    QTextEdit* m_teTerr;
    QTextEdit* m_teRegion;

    QGroupBox* m_MoveArmy;
    QGroupBox* m_Actions;
    QGroupBox* m_Roll;

    QPushButton* m_ViewCards;
    QPushButton* m_Next;
    QPushButton* m_btnRoll;
    QPushButton* m_btnMoveArmies;

    QSlider* m_numArmies;


    int m_numPlayers;

    void UpdateUI_SelectTerritories(Player* currentPlayer);
    void UpdateUI_StrengthenTerritories(Player* currentPlayer);
    void UpdateUI_Attack(Player* currentPlayer);
    void UpdateUI_Reinforce(Player* currentPlayer);
    void UpdateUI_TacticalMove(Player* currentPlayer);
    void UpdateUI_OriginalSettings();

     QPixmap m_blank;
     QPixmap m_RD1;
     QPixmap m_RD2;
     QPixmap m_RD3;
     QPixmap m_RD4;
     QPixmap m_RD5;
     QPixmap m_RD6;

     QPixmap m_WD1;
     QPixmap m_WD2;
     QPixmap m_WD3;
     QPixmap m_WD4;
     QPixmap m_WD5;
     QPixmap m_WD6;

     QPixmap m_Red;
     QPixmap m_Orange;
     QPixmap m_Yellow;
     QPixmap m_Green;
     QPixmap m_Blue;
     QPixmap m_Purple;

     Player* m_CurrentPlayer;


     QPixmap m_Shuttle;
     QPixmap m_Freshman;
     QPixmap m_GolfCart;
     QPixmap m_All;


     QPixmap m_CardBack;


};

#endif // GAMEBOARD_H
